<?php #Основной блок навигации
class admin_menu extends Load_use
{
	function getBlock()
	{
		if(!VIEW_ELOG_TO_ALL && !$this->user->allowed('access','admin_menu'))return false;
		$refer=false;
		$this->view->css('admin_menu');
		/*Обратная ссылка*/
		if($this->user->name && isset($_GET['get_refer']) && isset($_SERVER['HTTP_REFERER']))
		{
			$refer=$_SERVER['HTTP_REFERER'];
			if(!strpos('#'.$refer,'get_refer=1'))
				$refer.=(strpos('#'.$refer,'?')?'&':'?').'get_refer=1';
			$_SESSION['adm_menu_refer_'.(!is_site?'site':'admin')]=$refer;
		}
		$block = '
			<noindex>
				<header class="header">
					<nav class="main-navi">
						<ul>'.(!is_site?'<li><a href="'.($refer?$refer:'/?get_refer=1').'">Сайт</a></li>':'<li><a href="'.($refer?$refer:'/admin/?get_refer=1').'">Назад в Админку</a></li>');
			 
			
		if( $this->user->name )
		{
			$links = $this->cache->load('admin/admin_menu');
			$templ = $this->view->templ;
			if( !is_site && $templ != '_login' && $links && !isset( $links[$templ] ) )
			{
				$links = false;
				$this->cache->delete('admin/admin_menu');
			}
			$refef_link = ( site_mode == 'admin' ? '' : '&get_refer=1' );
			if( !$links )
				$links = $this->cache->get('admin/admin_menu','get_admin_menu');
			if($links)
				foreach($links as $link=>$name)
				{
					if($this->user->allowed('access',$link))
						$block .= '<li><a href="/admin/?p='.$link.$refef_link.'">'.$name.'</a></li>';
				}
				$block .= '
						</ul>
					</nav>';

				$block .= '
					<form action="" method="post" class="user-panel">
						<ul>
							<li>
								<dl>	
									<dt>'.$this->user->name.'</dt>
									<dd>'.$this->user->group_name.'</dd>
								</dl>	
							</li>
							<li>
								<input type="submit" value="Выйти" name="login[logout]" class="user-panel__button" />
							</li>
						</ul>
					</form>';
		}
		$log = '';
		if( $this->user->id == 8 || $this->user->id == 7 || $this->user->id == 1278 || $this->user->id == 1597 || $this->user->id == 3145 || $this->user->id == 3386 )
		{
			$log = '<span class="show_log">Показать/скрыть лог</span>
					<div class="div_log">
						'.$this->elog->getLog().'
					</div>';
		}	
	
		return $block
				.(is_site?'<a class="edit_page" href="/admin/?p=_pages&get_refer=1&par='.urlencode($this->view->parents).'&edit_id='.$this->view->id.'&templ='.$this->view->templ.'#page_edit">Редактировать страницу</a>':'').'
				</header>
			</noindex>'.$log;
	}
}